<html>
<head><meta charset="utf-8"><title>Stack overflow errors · project-error-handling · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/index.html">project-error-handling</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html">Stack overflow errors</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227717284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227717284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227717284">(Feb 25 2021 at 04:47)</a>:</h4>
<p>This is maybe a problem for the language/compiler, not just libs, but I would really like to see better error reporting for stack overflows:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">im_a_functional_programmer</span><span class="p">(</span><span class="n">a</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="kt">usize</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="n">im_a_functional_programmer</span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="fm">println!</span><span class="p">(</span><span class="s">"{}"</span><span class="p">,</span><span class="w"> </span><span class="n">im_a_functional_programmer</span><span class="p">(</span><span class="mi">100000000</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<div class="codehilite"><pre><span></span><code>$ cargo run
   Compiling rust-test v0.1.0 (/home/mario/Documents/rust-test)
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/rust-test`

thread &#39;main&#39; has overflowed its stack
fatal runtime error: stack overflow
fish: “cargo run” terminated by signal SIGABRT (Abort)
</code></pre></div>
<p>In particular, it is really important to get a stack trace to debug stack overflows! Rust is great about this <em>except</em> when the error is a stack overflow.</p>



<a name="227717488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227717488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227717488">(Feb 25 2021 at 04:50)</a>:</h4>
<p>There are also lots of cool things you can do with a stack trace for stack overflows like identify the cycle and present only that, rather than a mile long stack trace</p>



<a name="227717741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227717741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227717741">(Feb 25 2021 at 04:54)</a>:</h4>
<p>this is done with <code>backtrace-rs</code>https://docs.rs/backtrace/0.3.56/backtrace/</p>



<a name="227717929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227717929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227717929">(Feb 25 2021 at 04:57)</a>:</h4>
<p>the idea is to define a <code>Backtrace</code> trait in core and std</p>



<a name="227717938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227717938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227717938">(Feb 25 2021 at 04:57)</a>:</h4>
<p>Which part? The cycle detection?</p>



<a name="227717958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227717958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227717958">(Feb 25 2021 at 04:57)</a>:</h4>
<p>the stack tracing</p>



<a name="227718091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718091">(Feb 25 2021 at 04:58)</a>:</h4>
<p>Even if you hit stack overflow? My impression is that rust just aborts on this condition and there is no space for a lib to run any code</p>



<a name="227718125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718125">(Feb 25 2021 at 04:59)</a>:</h4>
<p>im not sure how stack overflows are handled</p>



<a name="227718141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718141">(Feb 25 2021 at 04:59)</a>:</h4>
<p>I do think that <code>backtrace-rs</code> can do the capture</p>



<a name="227718165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718165">(Feb 25 2021 at 04:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281739">oliver</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227718141">said</a>:</p>
<blockquote>
<p>I do think that <code>backtrace-rs</code> can do the capture</p>
</blockquote>
<p>i dont think that's the issue</p>



<a name="227718179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718179">(Feb 25 2021 at 05:00)</a>:</h4>
<p>well, prior art then</p>



<a name="227718225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718225">(Feb 25 2021 at 05:00)</a>:</h4>
<p>no i mean, during a stack overflow</p>



<a name="227718245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718245">(Feb 25 2021 at 05:00)</a>:</h4>
<p>you have no memory with which to run the functions to capture a stacktrace</p>



<a name="227718247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718247">(Feb 25 2021 at 05:00)</a>:</h4>
<p>im guessing?</p>



<a name="227718257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718257">(Feb 25 2021 at 05:00)</a>:</h4>
<p>tho this doesn't make a lot of sense to me</p>



<a name="227718263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718263">(Feb 25 2021 at 05:00)</a>:</h4>
<p>so I need to dig into this more</p>



<a name="227718276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718276">(Feb 25 2021 at 05:00)</a>:</h4>
<p>I dont even know if stack overflows trigger the panic handler</p>



<a name="227718331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718331">(Feb 25 2021 at 05:01)</a>:</h4>
<p>but it might be as simple as adding the call to backtrace printing used in the panic handler to whatever part of the runtime handles stack overflows</p>



<a name="227718340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718340">(Feb 25 2021 at 05:01)</a>:</h4>
<p>it clearly had enough stack space to report the error, so hopefully thats sufficient</p>



<a name="227718349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718349">(Feb 25 2021 at 05:01)</a>:</h4>
<p>and the only issue here is that it isn't integrated with that part of the runtime yet</p>



<a name="227718411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718411">(Feb 25 2021 at 05:02)</a>:</h4>
<p>This needs compiler support, but it might be possible to allocate a separate stack for the stack overflow handler. Alternatively, if the error type is owned and <code>'static</code> maybe you can just throw the main stack away and reuse it</p>



<a name="227718434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718434">(Feb 25 2021 at 05:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227718411">said</a>:</p>
<blockquote>
<p>This needs compiler support, but it might be possible to allocate a separate stack for the stack overflow handler. Alternatively, if the error type is owned and <code>'static</code> maybe you can just throw the main stack away and reuse it</p>
</blockquote>
<p>there shouldn't even necessarly be an error type associated with the overflow right, at least from the user's perspective</p>



<a name="227718435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718435">(Feb 25 2021 at 05:02)</a>:</h4>
<p>Who prints <code>fatal runtime error: stack overflow</code>?</p>



<a name="227718439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718439">(Feb 25 2021 at 05:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227718435">said</a>:</p>
<blockquote>
<p>Who prints <code>fatal runtime error: stack overflow</code>?</p>
</blockquote>
<p>checking now</p>



<a name="227718481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718481">(Feb 25 2021 at 05:03)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[allow(dead_code)]</span><span class="w"> </span><span class="c1">// stack overflow detection not enabled on all platforms</span>
<span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">report_overflow</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">dumb_print</span><span class="p">(</span><span class="fm">format_args!</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="s">"</span><span class="se">\n</span><span class="s">thread '{}' has overflowed its stack</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">thread</span>::<span class="n">current</span><span class="p">().</span><span class="n">name</span><span class="p">().</span><span class="n">unwrap_or</span><span class="p">(</span><span class="s">"&lt;unknown&gt;"</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">));</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="227718492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718492">(Feb 25 2021 at 05:03)</a>:</h4>
<p>from std/src/sys_common/util.rs</p>



<a name="227718601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718601">(Feb 25 2021 at 05:05)</a>:</h4>
<p>Which is called from <a href="https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/stack_overflow.rs#L105">https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/stack_overflow.rs#L105</a></p>



<a name="227718613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718613">(Feb 25 2021 at 05:05)</a>:</h4>
<p>and the windows one</p>



<a name="227718616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718616">(Feb 25 2021 at 05:05)</a>:</h4>
<p>yea</p>



<a name="227718666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718666">(Feb 25 2021 at 05:05)</a>:</h4>
<p>i think I know why this is not working</p>



<a name="227718668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718668">(Feb 25 2021 at 05:05)</a>:</h4>
<p>or i mean</p>



<a name="227718673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718673">(Feb 25 2021 at 05:05)</a>:</h4>
<p>why we can't do this from stack overflows yet</p>



<a name="227718714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718714">(Feb 25 2021 at 05:06)</a>:</h4>
<p>wait</p>



<a name="227718718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718718">(Feb 25 2021 at 05:06)</a>:</h4>
<p>no...</p>



<a name="227718722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718722">(Feb 25 2021 at 05:06)</a>:</h4>
<p>this is std code</p>



<a name="227718739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718739">(Feb 25 2021 at 05:06)</a>:</h4>
<p>ignore me</p>



<a name="227718883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718883">(Feb 25 2021 at 05:08)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> you should try grabbing the panic code from <code>default_hook</code></p>



<a name="227718897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718897">(Feb 25 2021 at 05:08)</a>:</h4>
<p>and put it into <code>report_overflow</code>, see what happens</p>



<a name="227718902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718902">(Feb 25 2021 at 05:08)</a>:</h4>
<p>backtrace code*</p>



<a name="227718903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718903">(Feb 25 2021 at 05:08)</a>:</h4>
<p>not panic</p>



<a name="227718911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718911">(Feb 25 2021 at 05:08)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">backtrace_env</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">panic_count</span>::<span class="n">get</span><span class="p">()</span><span class="w"> </span><span class="o">&gt;=</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">RustBacktrace</span>::<span class="n">Print</span><span class="p">(</span><span class="k">crate</span>::<span class="n">backtrace_rs</span>::<span class="n">PrintFmt</span>::<span class="n">Full</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">backtrace</span>::<span class="n">rust_backtrace_env</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="227718922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718922">(Feb 25 2021 at 05:08)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="n">backtrace_env</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">RustBacktrace</span>::<span class="n">Print</span><span class="p">(</span><span class="n">format</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="nb">drop</span><span class="p">(</span><span class="n">backtrace</span>::<span class="n">print</span><span class="p">(</span><span class="n">err</span><span class="p">,</span><span class="w"> </span><span class="n">format</span><span class="p">)),</span><span class="w"></span>
<span class="w">            </span><span class="n">RustBacktrace</span>::<span class="n">Disabled</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">            </span><span class="n">RustBacktrace</span>::<span class="n">RuntimeDisabled</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">if</span><span class="w"> </span><span class="n">FIRST_PANIC</span><span class="p">.</span><span class="n">swap</span><span class="p">(</span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="n">Ordering</span>::<span class="n">SeqCst</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="fm">writeln!</span><span class="p">(</span><span class="w"></span>
<span class="w">                        </span><span class="n">err</span><span class="p">,</span><span class="w"></span>
<span class="w">                        </span><span class="s">"note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace"</span><span class="w"></span>
<span class="w">                    </span><span class="p">);</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="227718931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718931">(Feb 25 2021 at 05:08)</a>:</h4>
<blockquote>
<p>there shouldn't even necessarly be an error type associated with the overflow right, at least from the user's perspective</p>
</blockquote>
<p>You're right. We still have to do some forensics on the main stack to work out the backtrace but I think we can just throw the stack away and reuse it if we need space for nice printing</p>



<a name="227718958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718958">(Feb 25 2021 at 05:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227718931">said</a>:</p>
<blockquote>
<blockquote>
<p>there shouldn't even necessarly be an error type associated with the overflow right, at least from the user's perspective</p>
</blockquote>
<p>You're right. We still have to do some forensics on the main stack to work out the backtrace but I think we can just throw the stack away and reuse it if we need space for nice printing</p>
</blockquote>
<p>messing with the stack is a bit lower level than I'm familiar with</p>



<a name="227718969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718969">(Feb 25 2021 at 05:09)</a>:</h4>
<p>might be good to bring this up with the compiler team</p>



<a name="227718970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718970">(Feb 25 2021 at 05:09)</a>:</h4>
<p>I assume that's what backtrace-rs is doing</p>



<a name="227718991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718991">(Feb 25 2021 at 05:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227718970">said</a>:</p>
<blockquote>
<p>I assume that's what backtrace-rs is doing</p>
</blockquote>
<p>I think backtrace-rs calls into libunwind</p>



<a name="227718994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718994">(Feb 25 2021 at 05:09)</a>:</h4>
<p>or w/e its called</p>



<a name="227718998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227718998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227718998">(Feb 25 2021 at 05:10)</a>:</h4>
<p>I haven't even tried modifying std before <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="227719000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719000">(Feb 25 2021 at 05:10)</a>:</h4>
<p>at least on unix</p>



<a name="227719056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719056">(Feb 25 2021 at 05:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227718998">said</a>:</p>
<blockquote>
<p>I haven't even tried modifying std before <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>
</blockquote>
<p>first time! woo!</p>



<a name="227719070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719070">(Feb 25 2021 at 05:10)</a>:</h4>
<p>rustc-dev-guide makes it pretty easy to get started</p>



<a name="227719157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719157">(Feb 25 2021 at 05:11)</a>:</h4>
<p>I need to figure out how rust signal handlers work. Surely we need some stack space just for that, since it's not written in assembler</p>



<a name="227719219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719219">(Feb 25 2021 at 05:12)</a>:</h4>
<p>like are we just hoping the compiler can inline and eliminate all locals?</p>



<a name="227719223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719223">(Feb 25 2021 at 05:12)</a>:</h4>
<p>/shrug</p>



<a name="227719232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719232">(Feb 25 2021 at 05:12)</a>:</h4>
<p>I wish I knew or could respond to these questions</p>



<a name="227719237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719237">(Feb 25 2021 at 05:12)</a>:</h4>
<p>but yea</p>



<a name="227719383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719383">(Feb 25 2021 at 05:14)</a>:</h4>
<p>Oh, actually a bit later in that file there is <code>NEED_ALTSTACK</code> and <code>sigaltstack</code>, so it sounds like there is a stack being allocated just for the signal handler</p>



<a name="227719395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719395">(Feb 25 2021 at 05:14)</a>:</h4>
<p>fancy</p>



<a name="227719399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719399">(Feb 25 2021 at 05:14)</a>:</h4>
<p>in which case there should be enough to print a basic stack trace, assuming no user code is called</p>



<a name="227719413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227719413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227719413">(Feb 25 2021 at 05:15)</a>:</h4>
<p>do it do it do it</p>



<a name="227723827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227723827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227723827">(Feb 25 2021 at 06:26)</a>:</h4>
<p>Don't know if this link will be of benefit to the conversation on "stack overflow errors" but I found this link for debugging the issue specifically for a mac:  <a href="https://dev.to/jasonelwood/setup-gdb-on-macos-in-2020-489k">https://dev.to/jasonelwood/setup-gdb-on-macos-in-2020-489k</a></p>



<a name="227729759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227729759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jakub Duchniewicz <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227729759">(Feb 25 2021 at 07:45)</a>:</h4>
<p>gdb is a useful tool (and lldb) but for stack overflows they would not help too much (just point to the place that overflows)</p>



<a name="227729895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227729895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jakub Duchniewicz <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227729895">(Feb 25 2021 at 07:46)</a>:</h4>
<p>and yeah, stack overflows with a backtrace would be useful (though for recursive calls we would get a long backtrace of almost useless info)</p>



<a name="227729932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227729932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jakub Duchniewicz <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227729932">(Feb 25 2021 at 07:47)</a>:</h4>
<p>maybe we should skip printing the long backtrace after e.g. 3 same func calls?</p>



<a name="227730080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227730080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227730080">(Feb 25 2021 at 07:49)</a>:</h4>
<p><span class="user-mention" data-user-id="344196">@Jakub Duchniewicz</span>  Thanks.  I'll file that info away <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="227730190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227730190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jakub Duchniewicz <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227730190">(Feb 25 2021 at 07:50)</a>:</h4>
<p>and ping me if you need help with using gdb, it can be pretty overwhelming at first glance (and is pretty powerful - even has TUI mode with -tui flag!)</p>



<a name="227730545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227730545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227730545">(Feb 25 2021 at 07:55)</a>:</h4>
<p>Thanks, I'll keep that offer in mind but I know absolutely nothing about stack overflows.  I just researched it and came across gdb and thought it might be of assistance to those looking into the issue.</p>



<a name="227765845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227765845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227765845">(Feb 25 2021 at 13:25)</a>:</h4>
<p>stack overflow produces as bad messages as they do now because you cannot really allocate anything on stack if you want to have any success of reporting the overflow</p>



<a name="227765913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227765913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227765913">(Feb 25 2021 at 13:25)</a>:</h4>
<p>separate stacks for signal handlers are not universal.</p>



<a name="227766054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227766054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227766054">(Feb 25 2021 at 13:26)</a>:</h4>
<p>If my memory serves me right, anyway.</p>



<a name="227766366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227766366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227766366">(Feb 25 2021 at 13:28)</a>:</h4>
<p>This also reminds me that people were complaining in the past that we don't always print "stack overflowed" message when there's an actual stack overflow. Our policy was always that this detection is on a best-effort basis. And if we start doing more (printing stack traces), people will have further expectations.</p>



<a name="227766595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227766595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227766595">(Feb 25 2021 at 13:30)</a>:</h4>
<p>I wonder if it wouldn't make sense to print out more information on any fault in that case.</p>



<a name="227766636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227766636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227766636">(Feb 25 2021 at 13:30)</a>:</h4>
<p>like go runtime IIRC prints stack trace, register values etc on sigquit too.</p>



<a name="227766861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227766861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227766861">(Feb 25 2021 at 13:32)</a>:</h4>
<p>I think it's okay if the enhanced stack overflow support is also best effort (but hopefully at least works on tier 1)</p>



<a name="227766998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227766998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227766998">(Feb 25 2021 at 13:33)</a>:</h4>
<p>you can't always figure out if a fault was caused by a stack overflow in the first place, even on T1 targets.</p>



<a name="227767145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227767145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227767145">(Feb 25 2021 at 13:34)</a>:</h4>
<p>The currently implemented method (watching for a guard page access) seems to be fairly reliable, although it has issues if you have really large stack frames</p>



<a name="227767297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227767297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227767297">(Feb 25 2021 at 13:35)</a>:</h4>
<p>but possibly the compiler can do some special handling for that - most C compilers already have to probe the stack when you put a giant array on the stack or use alloca to ensure that the guard page is hit</p>



<a name="227767391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227767391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227767391">(Feb 25 2021 at 13:36)</a>:</h4>
<p>I would assume rust gets that for free via LLVM</p>



<a name="227767426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227767426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227767426">(Feb 25 2021 at 13:36)</a>:</h4>
<p>but that doesn't necessarily work on embedded targets without a guard page</p>



<a name="227768632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227768632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227768632">(Feb 25 2021 at 13:45)</a>:</h4>
<p>I don't remember exact particularities, but it doesn't always work despite the probe.See e.g. <a href="https://users.rust-lang.org/t/is-rust-guaranteed-to-detect-stack-overflows/52593">https://users.rust-lang.org/t/is-rust-guaranteed-to-detect-stack-overflows/52593</a></p>



<a name="227806289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227806289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227806289">(Feb 25 2021 at 17:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227765845">said</a>:</p>
<blockquote>
<p>stack overflow produces as bad messages as they do now because you cannot really allocate anything on stack if you want to have any success of reporting the overflow</p>
</blockquote>
<p>I think the interface for backtrace printing used in panics is currently non-allocating though, so this might be fine?</p>



<a name="227819232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227819232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227819232">(Feb 25 2021 at 19:04)</a>:</h4>
<p>Hello - May you send me the audio link?  I thought I had it from the previous meeting...</p>



<a name="227877392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227877392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227877392">(Feb 26 2021 at 03:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/257204-project-error-handling/topic/Stack.20overflow.20errors/near/227718125">said</a>:</p>
<blockquote>
<p>im not sure how stack overflows are handled</p>
</blockquote>
<p>there's a stack guard I think</p>



<a name="227877432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Stack%20overflow%20errors/near/227877432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Stack.20overflow.20errors.html#227877432">(Feb 26 2021 at 03:35)</a>:</h4>
<p>oh sorry <span class="user-mention silent" data-user-id="123586">nagisa</span> already explained it better than I could</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>